import { Controller, Get, Put, Body, Post, Delete, Param } from "@nestjs/common";
import { ApiTags, ApiOperation } from "@nestjs/swagger";
import { MenuService } from "./menu.service";
import { MenuDto } from "./menu.dto";

@ApiTags('菜单')
@Controller('menu')
export class MenuController{
    constructor(
        private readonly menuService:MenuService,
    ){}

    @Get()
    @ApiOperation({summary:'查询所有菜单'})
    async find(){
        return await this.menuService.find()
    }

    @Put()
    @ApiOperation({summary:'新增菜单'})
    async add(@Body() menu:MenuDto){
        return this.menuService.add(menu);
    }

    @Delete(':id')
    @ApiOperation({summary:'删除菜单'})
    async remove(@Param('id') menuId){
        return await this.menuService.remove(menuId)
    }

    @Post()
    @ApiOperation({summary:'修改菜单'})
    async update(@Body() menu:MenuDto){
        return await this.menuService.update(menu)
    }
}